<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>pre-abs账户额度信息 新增</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
	<form id="fncPreAbsLimRecAdd_form" >
		<div class="fieldset1 tabel_col tabel_col_1 clearFix">
			<div class="fieldBox col_100 ">
				<div class="label">账号：</div>
				<div class="field">
					<input name="accNo" id="accNo" readonly=readonly type="text" class="ui-textbox" value="${accvo.accNum}" >
					<input name="insAccNoId" id="insAccNoId" type="hidden" class="ui-textbox" value="${id}">
					<input name="insId" id="insId" type="hidden" class="ui-textbox" value="${accvo.fundRasInsId}">
				</div>
				
			</div>
			
			<div class="fieldBox col_100 ">
				<div class="label">批次号：</div>
				<div class="field">
					<input name="batNo" id="batNo"  type="text" class="ui-textbox" value="" validate="{required:true}">
				</div>
				
			</div>
			<div class="fieldBox col_100 ">
				<div class="label">可投放事业部：</div>
				<div class="field">
					<input type="text"  name="buOrgCdsNm" id="buOrgCdsNm"  class="ui-textbox" >
					<input type="hidden" name="buOrgCds" id="buOrgCds" data-ligerid="buOrgCdsNm" value="">
				</div>
				
			</div>
			<div class="fieldBox col_100 ">
				<div class="label">总额度：</div>
				<div class="field">
					<input name="preLimAmt" id="preLimAmt" type="text" class="ui-textbox" value="" validate="{required:true}">
				</div>
			</div>
			<c:if test="${view=='1'}">
			<div class="fieldBox col_100 ">
				<div class="label">剩余额度：</div>
				<div class="field">
					<input name="currLimAmt" id="currLimAmt" type="text" class="ui-textbox" value="" validate="{required:true}">
				</div>
			</div>
			</c:if>
			<div class="fieldBox col_100 ">
				<div class="label">顺序：</div>
				<div class="field">
					<input name="payNum" id="payNum" type="text" class="ui-textbox" value="" >
				</div>
				
			</div>
			
			<!-- hide data -->
			<div class="fieldBox col_100 " style="display:none;">
				<div class="field">
					<input name="dataId" id="dataId" type="text" class="ui-textbox" value="${id}">
				</div>
			</div>
		</div>
	</form>
	<script type="text/javascript">
		$(function() {
		   
		   $("#buOrgCdsNm").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
           	   data: [
	                {  name: 'key', width: 100}, 
	                {  name: 'value', width: 120},
	               ],
	            url:'<%=path%>/rfbuss/fncpreabslim/getbuOrgCds.do',
	            ajaxType :'GET',
	            slide: false,
	            valueField: 'key', textField: 'value',
	            valueFieldID: 'buOrgCds'
           }); 
		   $("#fncPreAbsLimRecAdd_form").ligerForm({
               validate: true
          });
		   <c:if test="${view=='1'}">
	       initData();
	       </c:if>
	       //initcombobox();
		});
		
		//定义父级调用事件
		frameElement.dialog.onOk = function () {
			save();
		}
		
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("fncPreAbsLimRecAdd_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning("有验证信息未通过!");
                return false; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            data["insAccNoId"]=$("#insAccNoId").val();
            data["insId"]=$("#insId").val();
           data["buOrgCds"]=$("#buOrgCds").val();
           // var dataId = $("#dataId").val();
            var url = '<%=path%>/rfbuss/fncpreabslim/add.do';
                    

			AjaxUtils.ajaxPost(url, data, addCallback);
		}

		//新增回调
		function addCallback(msg) {
			if (msg.success == 1) {
				frameElement.dialog.close();
			} else {
				UIUtils.alertError(msg.info);
			}
		}

		//修改初始化数据
		function initData() {
			var dataId = $("#dataId").val();
			if (StringUtils.isEmpty(dataId))
				return;
			var _url = '<%=path%>/rfbuss/fncpreabslim/getByAccId.do';
			AjaxUtils.ajaxGet(_url, {
				id : dataId
			}, initCallback);
		}

		//初始化回调
		function initCallback(msg) {
			if (msg.success == 1) {
				setData(msg.data);//设置数据
			} else {
				UIUtils.alertError(msg.info);
			}
		}
		
		//修改时候设置页面数据
		function setData(data) {
			var form = new liger.get("fncPreAbsLimRecAdd_form");
			liger.get("buOrgCdsNm").selectValue(data.buOrgCds);
			form.setData({
				accNo : data.accNo,
				batNo : data.batNo,
				preLimAmt : data.preLimAmt/100,
				currLimAmt : data.currLimAmt/100,
				//buOrgCds : data.buOrgCds,
				
				
				payNum : data.payNum
			});
		};

		var limTypCdlist = [];
		<c:if test="${not empty limTypCdlist}"> limTypCdlist = ${limTypCdlist}; </c:if>
	
		 function initcombobox(){
			 alert(1111);
			 $("#limTypCd").ligerComboBox({
				 data:limTypCdlist,
	             selectBoxWidth: 270,
	             selectBoxHeight: 150,
	             valueField: "key",
	             textField: "value",
	     		    
	     		     }); 		 
		 }
		</script>

</body>
</html>